/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.MachineRoomBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class MachineRoomDAO
/*     */ {
/*  22 */   private static final Log log = LogFactory.getLog(MachineRoomDAO.class);
/*  23 */   private dbConnector dbcon = null;
/*  24 */   private SimpleDateFormat fresh = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*  25 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*     */ 
/*     */   private void dbConInit() {
/*  28 */     if (this.dbcon == null)
/*  29 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  33 */     if (this.dbcon != null)
/*  34 */       this.dbcon.closeAll();
/*  35 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getMachineRoomBOList(Map condition) {
/*  39 */     ListContentsBFO bfo = new ListContentsBFO();
/*  40 */     int start = Integer.parseInt(condition.get("start").toString());
/*  41 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  42 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  43 */     ResultSet rs = null;
/*  44 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  47 */       dbConInit();
/*  48 */       String strSQL = " select count(id) from machineroom where btscode = '" + strBtscode + "' ";
/*  49 */       log.info(strSQL);
/*  50 */       rs = this.dbcon.execQuery(strSQL);
/*  51 */       if (rs.next()) {
/*  52 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  54 */       strSQL = " select * from machineroom where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  55 */       log.info(strSQL);
/*  56 */       rs = this.dbcon.execQuery(strSQL);
/*  57 */       while (rs.next()) {
/*  58 */         MachineRoomBO bo = new MachineRoomBO();
/*  59 */         bo.setId(rs.getString("id"));
/*  60 */         bo.setBtscode(rs.getString("btscode"));
/*  61 */         bo.setBtsname(rs.getString("btsname"));
/*  62 */         bo.setFrame(rs.getString("frame"));
/*  63 */         bo.setAcreageT(rs.getString("acreageT"));
/*  64 */         bo.setPlan(rs.getString("plan"));
/*  65 */         bo.setProperty(rs.getString("property"));
/*  66 */         bo.setFromunit(rs.getString("fromunit"));
/*  67 */         bo.setOther(rs.getString("other"));
/*  68 */         bo.setContact(rs.getString("contact"));
/*  69 */         bo.setTelphone(rs.getString("telphone"));
/*  70 */         bo.setOpentime(rs.getDate("registtime"));
/*  71 */         bo.setWallheight(rs.getString("wallheight"));
/*  72 */         bo.setDoortype(rs.getString("doortype"));
/*  73 */         bo.setFacility(rs.getString("facility"));
/*  74 */         bo.setReason(rs.getString("reason"));
/*  75 */         bo.setWarnschilder(rs.getString("warnschilder"));
/*  76 */         bo.setAcreageU(rs.getString("acreageU"));
/*  77 */         bo.setPlace(rs.getString("place"));
/*  78 */         bo.setMaintenance(rs.getString("maintenance"));
/*  79 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  80 */         bo.setMemo(rs.getString("memo"));
/*  81 */         bo.setMroomIsLook(rs.getString("mroomIsLook"));
/*  82 */         bo.setMroomLookTel(rs.getString("mroomLookTel"));
/*  83 */         list.add(bo);
/*     */       }
/*  85 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  88 */       e.printStackTrace();
/*  89 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  92 */       dbConClose();
/*     */     }
/*  94 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveMachineRoomBO(MachineRoomBO bo)
/*     */   {
/*  99 */     log.info("添加--机房---开始");
/* 100 */     boolean flag = true;
/*     */     try
/*     */     {
/* 103 */       dbConInit();
/* 104 */       StringBuffer sqlBuf = new StringBuffer();
/* 105 */       sqlBuf.append(" insert into machineroom ( btscode, btsname, frame,  acreageT,");
/* 106 */       sqlBuf.append(" plan, property, fromunit, other, contact, telphone, registtime,");
/* 107 */       sqlBuf.append(" wallheight, doortype, facility, reason, warnschilder, acreageU,");
/* 108 */       sqlBuf.append(" place, maintenance, refreshtime, memo, mroomIsLook,");
/* 109 */       sqlBuf.append(" mroomLookTel   ) values ( ");
/* 110 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/* 111 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 112 */       sqlBuf.append(" '" + bo.getFrame() + "' ,");
/* 113 */       sqlBuf.append(" '" + bo.getAcreageT() + "' ,");
/* 114 */       sqlBuf.append(" '" + bo.getPlan() + "' ,");
/* 115 */       sqlBuf.append(" '" + bo.getProperty() + "' ,");
/* 116 */       sqlBuf.append(" '" + bo.getFromunit() + "' ,");
/* 117 */       sqlBuf.append(" '" + bo.getOther() + "' ,");
/* 118 */       sqlBuf.append(" '" + bo.getContact() + "' ,");
/* 119 */       sqlBuf.append(" '" + bo.getTelphone() + "' ,");
/* 120 */       sqlBuf.append(" '" + this.open.format(bo.getOpentime()) + "' ,");
/* 121 */       sqlBuf.append(" '" + bo.getWallheight() + "' ,");
/* 122 */       sqlBuf.append(" '" + bo.getDoortype() + "' ,");
/* 123 */       sqlBuf.append(" '" + bo.getFacility() + "' ,");
/* 124 */       sqlBuf.append(" '" + bo.getReason() + "' ,");
/* 125 */       sqlBuf.append(" '" + bo.getWarnschilder() + "' ,");
/* 126 */       sqlBuf.append(" '" + bo.getAcreageU() + "' ,");
/* 127 */       sqlBuf.append(" '" + bo.getPlace() + "' ,");
/* 128 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/*     */ 
/* 130 */       sqlBuf.append(" '" + this.fresh.format(new Date()) + "' ,");
/* 131 */       sqlBuf.append(" '" + bo.getMemo() + "' ,");
/* 132 */       sqlBuf.append(" '" + bo.getMroomIsLook() + "' ,");
/*     */ 
/* 134 */       sqlBuf.append(" '" + bo.getMroomLookTel() + "' )");
/* 135 */       log.info(sqlBuf.toString());
/* 136 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 140 */       flag = false;
/* 141 */       e.printStackTrace();
/* 142 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 145 */       dbConClose();
/*     */     }
/* 147 */     log.info("添加--机房---结束");
/* 148 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateMachineRoomBO(MachineRoomBO bo)
/*     */   {
/* 153 */     log.info("修改--机房---开始");
/* 154 */     boolean flag = true;
/*     */     try
/*     */     {
/* 157 */       dbConInit();
/* 158 */       StringBuffer sqlBuf = new StringBuffer();
/* 159 */       sqlBuf.append(" update  machineroom set ");
/* 160 */       sqlBuf.append(" frame = '" + bo.getFrame() + "' ,");
/* 161 */       sqlBuf.append(" acreageT = '" + bo.getAcreageT() + "' ,");
/* 162 */       sqlBuf.append(" plan = '" + bo.getPlan() + "' ,");
/* 163 */       sqlBuf.append(" property = '" + bo.getProperty() + "' ,");
/* 164 */       sqlBuf.append(" fromunit = '" + bo.getFromunit() + "' ,");
/* 165 */       sqlBuf.append(" other = '" + bo.getOther() + "' ,");
/* 166 */       sqlBuf.append(" contact = '" + bo.getContact() + "' ,");
/* 167 */       sqlBuf.append(" telphone = '" + bo.getTelphone() + "' ,");
/* 168 */       sqlBuf.append(" registtime = '" + this.open.format(bo.getOpentime()) + "' ,");
/* 169 */       sqlBuf.append(" wallheight = '" + bo.getWallheight() + "' ,");
/* 170 */       sqlBuf.append(" doortype = '" + bo.getDoortype() + "' ,");
/* 171 */       sqlBuf.append(" facility = '" + bo.getFacility() + "' ,");
/* 172 */       sqlBuf.append(" reason = '" + bo.getReason() + "' ,");
/* 173 */       sqlBuf.append(" warnschilder = '" + bo.getWarnschilder() + "' ,");
/* 174 */       sqlBuf.append(" acreageU = '" + bo.getAcreageU() + "' ,");
/* 175 */       sqlBuf.append(" place = '" + bo.getPlace() + "' ,");
/* 176 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/*     */ 
/* 178 */       sqlBuf.append(" refreshtime = '" + this.fresh.format(new Date()) + "' ,");
/* 179 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ,");
/* 180 */       sqlBuf.append(" mroomIsLook = '" + bo.getMroomIsLook() + "' ,");
/*     */ 
/* 182 */       sqlBuf.append(" mroomLookTel = '" + bo.getMroomLookTel() + "' ");
/* 183 */       sqlBuf.append(" where id='" + bo.getId() + "' ");
/* 184 */       log.info(sqlBuf.toString());
/* 185 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 189 */       flag = false;
/* 190 */       e.printStackTrace();
/* 191 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 194 */       dbConClose();
/*     */     }
/* 196 */     log.info("修改--机房---结束");
/* 197 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteMachineRoomBO(String strID)
/*     */   {
/* 202 */     log.info("删除--机房---开始");
/* 203 */     boolean flag = true;
/*     */     try
/*     */     {
/* 206 */       dbConInit();
/* 207 */       StringBuffer sqlBuf = new StringBuffer();
/* 208 */       sqlBuf.append(" delete from  machineroom ");
/* 209 */       sqlBuf.append(" where id='" + strID + "' ");
/* 210 */       log.info(sqlBuf.toString());
/* 211 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 215 */       flag = false;
/* 216 */       e.printStackTrace();
/* 217 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 220 */       dbConClose();
/*     */     }
/* 222 */     log.info("删除--机房---结束");
/* 223 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getMachineRoomByBtsName(Map condition)
/*     */   {
/* 228 */     ListContentsBFO bfo = new ListContentsBFO();
/* 229 */     int start = Integer.parseInt(condition.get("start").toString());
/* 230 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 231 */     String strBtsName = condition.get("btsName").toString();
/* 232 */     ResultSet rs = null;
/* 233 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 236 */       dbConInit();
/*     */ 
/* 238 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 239 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 241 */       String strSQL = " select count(id) from machineroom where btsname like '%" + strBtsName + "%' ";
/* 242 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 243 */       log.info(strSQL);
/* 244 */       rs = this.dbcon.execQuery(strSQL);
/* 245 */       if (rs.next()) {
/* 246 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 248 */       strSQL = " select * from machineroom where btsname like '%" + strBtsName + "%' ";
/* 249 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 250 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 251 */       rs = this.dbcon.execQuery(strSQL);
/* 252 */       while (rs.next()) {
/* 253 */         MachineRoomBO bo = new MachineRoomBO();
/* 254 */         bo.setId(rs.getString("id"));
/* 255 */         bo.setBtscode(rs.getString("btscode"));
/* 256 */         bo.setBtsname(rs.getString("btsname"));
/* 257 */         bo.setFrame(rs.getString("frame"));
/* 258 */         bo.setAcreageT(rs.getString("acreageT"));
/* 259 */         bo.setPlan(rs.getString("plan"));
/* 260 */         bo.setProperty(rs.getString("property"));
/* 261 */         bo.setFromunit(rs.getString("fromunit"));
/* 262 */         bo.setOther(rs.getString("other"));
/* 263 */         bo.setContact(rs.getString("contact"));
/* 264 */         bo.setTelphone(rs.getString("telphone"));
/* 265 */         bo.setOpentime(rs.getDate("registtime"));
/* 266 */         bo.setWallheight(rs.getString("wallheight"));
/* 267 */         bo.setDoortype(rs.getString("doortype"));
/* 268 */         bo.setFacility(rs.getString("facility"));
/* 269 */         bo.setReason(rs.getString("reason"));
/* 270 */         bo.setWarnschilder(rs.getString("warnschilder"));
/* 271 */         bo.setAcreageU(rs.getString("acreageU"));
/* 272 */         bo.setPlace(rs.getString("place"));
/* 273 */         bo.setMaintenance(rs.getString("maintenance"));
/* 274 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 275 */         bo.setMemo(rs.getString("memo"));
/* 276 */         bo.setMroomIsLook(rs.getString("mroomIsLook"));
/* 277 */         bo.setMroomLookTel(rs.getString("mroomLookTel"));
/* 278 */         list.add(bo);
/*     */       }
/* 280 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 283 */       e.printStackTrace();
/* 284 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 287 */       dbConClose();
/*     */     }
/* 289 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 294 */     ResultSet rs = null;
/* 295 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 298 */       dbConInit();
/* 299 */       String strSQL = " select * from machineroom where btsname like '%" + strBtsName + "%'   ";
/* 300 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 301 */       log.info(strSQL);
/* 302 */       rs = this.dbcon.execQuery(strSQL);
/* 303 */       while (rs.next()) {
/* 304 */         MachineRoomBO bo = new MachineRoomBO();
/* 305 */         bo.setId(rs.getString("id"));
/* 306 */         bo.setBtscode(rs.getString("btscode"));
/* 307 */         bo.setBtsname(rs.getString("btsname"));
/* 308 */         bo.setFrame(rs.getString("frame"));
/* 309 */         bo.setAcreageT(rs.getString("acreageT"));
/* 310 */         bo.setPlan(rs.getString("plan"));
/* 311 */         bo.setProperty(rs.getString("property"));
/* 312 */         bo.setFromunit(rs.getString("fromunit"));
/* 313 */         bo.setOther(rs.getString("other"));
/* 314 */         bo.setContact(rs.getString("contact"));
/* 315 */         bo.setTelphone(rs.getString("telphone"));
/* 316 */         bo.setOpentime(rs.getDate("registtime"));
/* 317 */         bo.setWallheight(rs.getString("wallheight"));
/* 318 */         bo.setDoortype(rs.getString("doortype"));
/* 319 */         bo.setFacility(rs.getString("facility"));
/* 320 */         bo.setReason(rs.getString("reason"));
/* 321 */         bo.setWarnschilder(rs.getString("warnschilder"));
/* 322 */         bo.setAcreageU(rs.getString("acreageU"));
/* 323 */         bo.setPlace(rs.getString("place"));
/* 324 */         bo.setMaintenance(rs.getString("maintenance"));
/* 325 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 326 */         bo.setMemo(rs.getString("memo"));
/* 327 */         bo.setMroomIsLook(rs.getString("mroomIsLook"));
/* 328 */         bo.setMroomLookTel(rs.getString("mroomLookTel"));
/* 329 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 333 */       e.printStackTrace();
/* 334 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 337 */       dbConClose();
/*     */     }
/* 339 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.MachineRoomDAO
 * JD-Core Version:    0.6.2
 */